# 计算众文档平均概率向量

import sys
import pickle

from ..lda import calculate_mass_article_probability_vector, get_lda_model
from ..glda import calculate_glda_mapv


def run():
    model_fp = sys.argv[2]
    corpus_fp = sys.argv[3]
    if corpus_fp == 'glda':
        mapv = calculate_glda_mapv(model_fp)
    else:
        lda_model = get_lda_model(model_fp)
        mapv = calculate_mass_article_probability_vector(corpus_fp, lda_model)
    mapv_fp = '%s.mapv' % model_fp
    with open(mapv_fp, 'wb') as fo:
        pickle.dump(mapv, fo)
